import modelExtend from 'dva-model-extend';

export const commonModel = {
    reducers: {
        updateState (state, { payload }) {
            return {
                ...state,
                ...payload,
            }
        }
    }
};

export const pageModel = modelExtend(commonModel, {
    state: {
        list: [],
        pagination: {
            pageSize: 10,
            current: 1,
            total: 0,
        },
    },
    reducers: {
        querySuccess (state, { payload }) {
            const { list, pagination } = payload;
            return {
                ...state,
                list,
                pagination: {
                    ...state.pagination,
                    ...pagination,
                },
            }
        },
    }
});
